﻿namespace NJQuery {
	using System;
	using System.ComponentModel;
	using System.Globalization;

	/// <summary>
	/// Provides conversions for the <see cref="DayNameCollection"/>.
	/// </summary>
	public class DayNameCollectionConverter : ExpandableObjectConverter {


		#region Static Properties: Override sort order

		private readonly string[] propertyNames = { "Culture", "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" };

		#endregion


		#region Methods: Filter

		/// <summary>
		/// Gets a collection of properties for the type of object specified by the value parameter.
		/// </summary>
		/// <param name="context">A <see cref="ITypeDescriptorContext"/> that provides a format context.</param>
		/// <param name="value">A <see cref="Object"/> that specifies the type of object to get the properties for.</param>
		/// <param name="attributes">An array of type <see cref="Attribute"/> that will be used as a filter.</param>
		/// <returns>A collection of properties.</returns>
		public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes) {
			PropertyDescriptorCollection properties = base.GetProperties(context, value, attributes);
			return properties.Sort(propertyNames);
		}

		#endregion


	}

}